<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="utf-8" xmlns:th="http://www.thymeleaf.org"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>发布</title>
    <script th:src="@{/js/layui.js}"></script>
    <script th:src="@{/js/layer.js}"></script>
    <script th:src="@{/js/jquery-1.10.1.js}"></script>
    <link href="css/demo.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet"   type="text/css" th:href="@{/css/demo.css}" >
    <link rel="stylesheet"   type="text/css" th:href="@{/css/layui.css}" href="/skin/layui/css/layui.css">
    <!--End Framework-->
    <meta name="applicable-device" content="mobile">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,maximum-scale=1">
    <meta name="robots" content="all">
    <meta name="format-detection" content="telephone=no">

</head>

<body class="flipInX animated">
<section id="getintouch" class="fadeInRightBig animated">
    <div class="container myc" style="border-bottom: 0;">
        <h1>
            <span>发布失物招领</span>
        </h1>
    </div>
    <div class="container">
        <form class="contact" action="#" method="post" id="form" enctype="multipart/form-data" onSubmit="return beforeSubmit(this);" name="form">
            <div class="row clearfix">
                <div class="lbl">
                    <label for="name">
                        拾取地点</label>
                </div>
                <input type="text" id="a" name="address"  placeholder="填写详细拾取地点">
            </div>
            <div class="row clearfix">
                <div class="lbl">
                    <label for="name">
                        拾取物品</label>
                </div>
                <div class="ctrl">
                    <input type="text" name="goods"   placeholder=" 物品名称" >

                </div>
            </div>
            <div class="row clearfix">
                <div class="lbl">
                    <label  >
                        拾取时间</label>
                </div>
                <divd class="ctrl">
                    <input type="text" class="layui-input" id="test1" name="time" placeholder="填写拾取日期">
                </divd>
            </div>
            <div class="row clearfix">
                <div class="lbl">
                    <label for="name">
                        联系人</label>
                </div>
                <div class="ctrl">
                    <input type="text" id="name" name="lxr"  placeholder="联系人姓名">
                </div>
            </div>
            <div class="row clearfix">
                <div class="lbl">
                    <label for="email">
                        电话</label>
                </div>
                <div class="ctrl">
                    <input type="text" id="email" name="mobile"
                             placeholder="手机号码">
                </div>
            </div>
            <div class="row clearfix">
                <div class="lbl">
                    <label for="message">
                        备注</label>
                </div>
                <div class="ctrl">
                    <textarea id="message" name="body" rows="6" cols="10"></textarea>
                </div>
            </div>


            <div class="row  clearfix"><div class="lbl">
                <label>上传图片：</label></div>
                <div class="ctrl">
                    <div style="display: none" id='myss'> <img id="img" src="">
                        <div style="height: 20px"></div>
                    </div>
                    <input id="upload" type="file"  name="file">
                    <input type="hidden" value="" name="image" id='image'>
                </div>
            </div>

            <input type="hidden" value="1554089298" name="senddate">
            <input type="hidden" value="1554089298" name="sortrank">
            <input type="hidden" value="1554089298" name="arcrank">
            <input type="hidden" value="" name="typeid">
            <input type="hidden" value="" name="channelid">
            <input type="hidden" value="" name="type">
            <div class="row  clearfix">
                <div class="span10 offset2">
                    <input type="button" name="submit" id="publish"  class="submit" value="确认发布">
                </div>
            </div>
            <div style="clear: both"></div>
        </form>
        <div style="clear: both"></div>
    </div>
    <div style="clear: both"></div>
</section>
<div style="clear: both"></div>
<script>
    $('#publish').on('click', function(){
        var file = document.getElementById('upload').files[0];
        var formdata = new FormData();

        var address=$("input[name='address']").val();
        var goods=$("input[name='goods']").val();
        var lxr=$("input[name='lxr']").val();
        var body=$("textarea[name='body']").val();
        var time=$("input[name='time']").val();
        var mobile=$("input[name='mobile']").val();
        if (address==""||goods==""||lxr==""||time==""||mobile==""||file==""){
            alert("请将信息填写完整")
        }else {
            formdata.append("file",file);
            formdata.append("goodsName",goods);
            formdata.append("goodsAddress",address);
            formdata.append("goodsRealname",lxr);
            formdata.append("goodsDescription",body);
            formdata.append("goodsDate",time);
            formdata.append("goodsMobile",mobile);
            $.ajax({
                url: "/publistcollectpost",
                data: formdata,
                type: "post",
                processData: false,
                contentType: false,
                success: function(result) {
                        alert("提交申请成功");
                        location.href='/home';
                },
                error: function() {
                    console.log("发布失败");
                }
            })
        }

    })
</script>

</body>
</html>
